year = int(input())
month = int(input())
day = int(input())

days = day
for i in range(1,month):
    if i in (1,3,5,7,8,10,12):
        days += 31
    elif i in (4,6,9,11):
        days += 30
    elif i == 2:
        if year%400==0 or year%100!=0 and year%4==0:
            days += 29
        else:
            days += 28

print(days)
